package com.guanyong.webapi.controllers.api;

import com.guanyong.utils.Comm.ResultObject;
import com.guanyong.webapi.config.VideoLocalUtil;
import com.guanyong.webapi.config.VoucherUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;

/**
 * Created by mxk on 2017/7/16.
 */
@RestController
@RequestMapping("/api/imgRecommend/")
public class ImgRecommend {


    @RequestMapping(value = "getRecommend", method = RequestMethod.GET)
    public ResultObject<Map<String,Object>> getRecommend(HttpServletRequest request){

        ResultObject<Map<String,Object>> resultObject=new
                ResultObject<Map<String,Object>>();

            Map<String,Object> map = new HashMap<String, Object>();

                int r=new Random().nextInt(4);
                if (r==0){
                    map.put("img","http://101.201.122.79:8083/Images/upload/videoPhoto/20170819172025.jpg");
                    map.put("url","http://www.baidu.com");
                }else if(r==1){
                    map.put("img","http://101.201.122.79:8083/Images/upload/videoPhoto/20170819172025.jpg");
                    map.put("url","http://101.201.122.79:8080/download/app-debug.apk");
                }else if (r==2){
                    map.put("img","http://101.201.122.79:8083/Images/upload/videoPhoto/20170819172025.jpg");
                    map.put("url","http://103.210.238.151:8082/movie/修道院惊魂.mp4");
                }else{
                }
                resultObject.setResult(map);
        return  resultObject;

    }

    @RequestMapping(value = "openAppAdvertisement", method = RequestMethod.GET)
    public ResultObject<Map<String,Object>> openAppAdvertisement(HttpServletRequest request){

        ResultObject<Map<String,Object>> resultObject=new
                ResultObject<Map<String,Object>>();

        Map<String,Object> map = new HashMap<String, Object>();

        int r=new Random().nextInt(4);

        if (r==0){
            map.put("img","http://101.201.122.79:8083/Images/upload/videoPhoto/20170822164954.jpg");
            map.put("url","http://101.201.122.79:8080/download/app-debug.apk");
            map.put("time","3");
        }else if(r==1){
            map.put("img","http://101.201.122.79:8083/Images/upload/videoPhoto/20170822164954.jpg");
            map.put("url","http://101.201.122.79:8080/download/app-debug.apk");
            map.put("time","5");
        }else if (r==2){
            map.put("img","http://101.201.122.79:8083/Images/upload/videoPhoto/20170822164954.jpg");
            map.put("url",null);
        }else{

        }
        resultObject.setResult(map);
        return  resultObject;

    }

    @RequestMapping(value = "getOpen", method = RequestMethod.GET)
    public ResultObject<Map<String,Object>> getOpen(HttpServletRequest request){
        ResultObject<Map<String,Object>> resultObject=new
                ResultObject<Map<String,Object>>();
        Map<String,Object> map = new HashMap<String, Object>();
//        没有电影只有海报内容模式
//        map.put("showType",0);
//        有电影资源模式
        map.put("showType",1);

        resultObject.setResult(map);
        return  resultObject;
    }



}
